import Vue from 'vue'
import ConfirmPlug from '../components/plugins/Confirm'
var vm = null
var LuiConfirm = {}
LuiConfirm.install = function(Vue, options) {
  Vue.component('lui-confirm', ConfirmPlug)
  // 4. 添加实例方法
  Vue.prototype.$confirm = function(methodOptions) {
    let _opt = Object.assign(
      {
        title: '提示',
        body: '继续执行？'
      },
      methodOptions
    )
    if (!vm) {
      let LuiConfirmTpl = Vue.extend(ConfirmPlug)
      vm = new LuiConfirmTpl(options)
      var tpl = vm.$mount().$el
      document.body.appendChild(tpl)
    }
    return vm.show(_opt)
  }
}
export default LuiConfirm
